package com.example.demo.service;

import com.example.demo.Dao.FitDao;
import com.example.demo.entity.Course;
import com.example.demo.entity.Employee;
import com.example.demo.entity.MC;
import com.example.demo.entity.Member;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
//服务层  直接实现功能业务

@Service
public class FitService {
    private final FitDao fd;

    public FitService(FitDao fd) {
        this.fd = fd;
    }


    // 获取健身卡选项
    public List<Map<String, Object>> getCardOptions() {
        return fd.getCardOptions();
    }

    // 获取会籍选项
    public List<Map<String, Object>> getHuijiOptions() {
        return fd.getHuijiOptions();
    }

    // 添加新会员
    public void addMember(Member member) {
        // 转换性别表示：前端使用字符串 "true"/"false"，后端使用 "男"/"女"
        if ("true".equals(member.getMemberSex())) {
            member.setMemberSex("男");
        } else if ("false".equals(member.getMemberSex())) {
            member.setMemberSex("女");
        }
        fd.addMember(member);
    }

    //获取会员
    public List<Member> getAllMembers() {
        return fd.getAllMembers();
    }

    public List<Member> getMember(String memberNum) {
        return fd.getMember(memberNum);
    }

    public void deleteMember(String memberNum) {
        fd.deleteMember(memberNum);
    }

    public void updateMember(Member member) {
        fd.updateMember(member);
    }

    public List<Course> getAllCourses() {
        return fd.getAllCourses();
    }

    public void addCourse(Course course) {
        fd.addCourse(course);
    }

    public List<String> getCourseNum(String courseName) {
        return fd.getCourseNum(courseName);
    }

    //查询教练员工
    public List<Employee> getCoaches() {
        return fd.getEmployeesByType("教练");
    }

    public List<Employee> getMembershipStaff() {
        return fd.getEmployeesByType("会籍顾问");
    }

    public void addMC(MC mc) {
        fd.addMC(mc);
    }

    public void addEmployee(Employee employee) {
        fd.addEmployee(employee);
    }

    public void updateEmployee(Employee employee) {
        fd.updateEmployee(employee);
    }

    public void deleteEmployee(String eeNum) {
        fd.deleteEmployee(eeNum);
    }

    public List<MC> getAllMC() {
        return fd.getAllMC();
    }

    public void deleteMC(String memberNum, String courseNum) {
        fd.deleteMC(memberNum, courseNum);
    }

    public void deleteCourse(String courseNum) {
        fd.deleteCourse(courseNum);
    }
}